<?php

namespace App\Http\Controllers\UserApi;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\UserIntegral;

class UserIntegralController extends BaseController
{
    //
    public function apply_integral(Request $request,UserIntegral $integral){
        $res = $integral->insert([
            'user_id'=>auth('api')->user()->id,
            'integral'=>$request->integral,
            'proof_img'=>$request->proof_img,
            'created_at'=>date("Y-m-d H:i:s")
        ]);
        if($res){
           return $this->success($res,200,'等待审核申请成功');
        }
        return $this->fail('失败');
    }

    public function my_integral(Request $request,UserIntegral $integral){
        $data = $integral->where('user_id',auth('api')->user()->id)->paginate(6);
        return $this->success($data);

    }
}
